﻿//#define CA1008
//#define CA1009
//#define CA1009err
//#define CA1012
//#define CA1012err
//#define CA1050
#define CA2217

using System;

public class ClassWithoutNamespace
{
}

namespace FxCopRulesTest
{
    #region Types

    // CA1008
    enum EnumWithoutZerovaluedMember
    {
        One = 1,
        Two = 2,
        Three = 3
    }

    // CA1009
    class ClassWithIncorrectlyDeclaredEventHandler
    {
        public ClassWithIncorrectlyDeclaredEventHandler()
        {
#if CA1009
            this.Event += new EventHandler(ClassWithIncorrectlyDeclaredEventHandler_Event);
            this.Event += new EventHandler(ClassWithIncorrectlyDeclaredEventHandler_Event1);
#if CA1009err
            this.Event += new EventHandler(ClassWithIncorrectlyDeclaredEventHandler_Event2);
#endif
#endif
        }

        event EventHandler Event;

        public void RaiseEvent()
        {
            if (Event != null)
                this.Event(this, EventArgs.Empty);
        }

        // Nem megfelelő paraméternevek
        // 
        void ClassWithIncorrectlyDeclaredEventHandler_Event(object s, EventArgs ea)
        {
            ;
        }

        // Nem megfelelő paraméternevek
        // 
        void ClassWithIncorrectlyDeclaredEventHandler_Event1(object s, EventArgs ea)
        {
            ;
        }

        // Nem megfelelő szignatúra
        // 
        bool ClassWithIncorrectlyDeclaredEventHandler_Event2(object s, EventArgs ea, int i)
        {
            return true;
        }
    }

    // CA1012
    abstract class AbstractClassWithPublicConstructor
    {
        public AbstractClassWithPublicConstructor() { }
    }

    // CA2217
    [Flags]
    public enum InvalidFlagEnum
    {
        None = 0,
        A = 1,
        B = 2,
        C = 3,
        D = 7
    }

    #endregion Types

    class Program
    {
        static void Main(string[] args)
        {
#if CA1008
            EnumWithoutZerovaluedMember e = new EnumWithoutZerovaluedMember();
            switch (e)
            {
                case EnumWithoutZerovaluedMember.One:
                    break;
                case EnumWithoutZerovaluedMember.Two:
                    break;
                case EnumWithoutZerovaluedMember.Three:
                    break;
                default:
                    break;
            }
#endif //CA1008
#if CA1009
            ClassWithIncorrectlyDeclaredEventHandler c = new ClassWithIncorrectlyDeclaredEventHandler();
            c.RaiseEvent();
#endif //CA1009
#if CA1012err
            AbstractClassWithPublicConstructor a = new AbstractClassWithPublicConstructor();
#endif //CA1012err
#if CA1050
            ClassWithoutNamespace c;
#endif //CA1050
#if CA2217
            InvalidFlagEnum ife = InvalidFlagEnum.A | InvalidFlagEnum.D;
            if (((ife & InvalidFlagEnum.A) != InvalidFlagEnum.A)
                || ((ife & InvalidFlagEnum.B) == InvalidFlagEnum.B)
                || ((ife & InvalidFlagEnum.C) != InvalidFlagEnum.C)
                || ((ife & InvalidFlagEnum.D) == InvalidFlagEnum.D))
                Console.WriteLine("CA2217: InvalidFlagEnum FAILED");
#endif //CA2217

            Console.ReadLine();
        }
    }
}
